package xkp.lesson5;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class TestStream2 {
    public static void main(String[] args) {
        List<Employee> employeeList = Arrays.asList(
                new Employee(1,"张三",20,3000.00),
                new Employee(2,"李四",21,4000.00),
                new Employee(3,"王五",22,5000.00),
                new Employee(4,"赵柳",23,6000.00),
                new Employee(5,"天气",24,7000.00),
                new Employee(6,"员工6",25,8000.00),
                new Employee(7,"员工7",26,9000.00),
                new Employee(8,"员工8",27,10000.00),
                new Employee(9,"员工9",28,11000.00)
        );
        //过滤员工信息
        //按照年龄过滤大于23的员工信息并保存为一个新的List
        //employeeList.stream().filter(t->t.getAge()>23).forEach(System.out::println);
        List<Employee> newList = employeeList.stream().filter(t->t.getAge()>23).collect(Collectors.toList());
        employeeList.get(5).setAge(100);
        newList.forEach(System.out::println);
    }
}
